package top.fangw.tenant.controller;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.fangw.common.api.dto.Oauth2RegisteredClientDto;
import top.fangw.common.core.result.Result;
import top.fangw.common.log.annotation.Log;
import top.fangw.tenant.pojo.entity.DatasourceInfo;
import top.fangw.tenant.pojo.entity.Oauth2RegisteredClient;
import top.fangw.tenant.service.IOauth2RegisteredClientService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fangw
 * @since 2024-02-22
 */
@Tag(name = "客户端管理")
@RestController
@RequestMapping("/oauth2-registered-client")
@RequiredArgsConstructor
public class Oauth2RegisteredClientController {

    private final IOauth2RegisteredClientService oauth2RegisteredClientService;

    @Log
    @Operation(summary ="添加数据源信息")
    @GetMapping("/geyByClientId")
    public Result<?> geyByClientId(@RequestParam String clientId) {
        Oauth2RegisteredClient res = oauth2RegisteredClientService.geyByClientId(clientId);
        return Result.success(res);
    }
    @Log
    @Operation(summary ="添加数据源信息")
    @GetMapping("/geyByClientIdFeign")
    public Result<Oauth2RegisteredClientDto> geyByClientIdFeign(@RequestParam String clientId) {
        Oauth2RegisteredClient res = oauth2RegisteredClientService.geyByClientId(clientId);
        Oauth2RegisteredClientDto oauth2RegisteredClientDto = BeanUtil.copyProperties(res, Oauth2RegisteredClientDto.class);
        return Result.success(oauth2RegisteredClientDto);
    }
    @Log
    @Operation(summary ="添加数据源信息")
    @GetMapping("/getByIdIdFeign")
    public Result<Oauth2RegisteredClientDto> getByIdFeign(@RequestParam String clientId) {
        Oauth2RegisteredClient res = oauth2RegisteredClientService.getById(clientId);
        Oauth2RegisteredClientDto oauth2RegisteredClientDto = BeanUtil.copyProperties(res, Oauth2RegisteredClientDto.class);
        return Result.success(oauth2RegisteredClientDto);
    }

}
